/**
 * ...
 * @author Franco Ponticelli
 */

package uform.ui.comp;
import uform.property.LimitedStringPropertyDecorator;
import uform.ui.comp.Control;
import uform.ui.comp.Component;
import uform.property.IProperty;
import uform.property.Property;
import uform.ui.comp.StringKind;

class StringControl extends Control<String>
{
	public var maxLength(default, null) : IProperty<Null<Int>>;
	public var kind(default, null) : IProperty<StringKind>;
	
	public function new(name : String, kind : StringKind, ?value : String)
	{
		super(name, value);
		this.value.setDefault("");
		var property = new LimitedStringPropertyDecorator(this.value);
		this.value = property;
		maxLength = new Property(null);
		var me = this;
		maxLength.onChange.add(function() {
			property.maxLength = me.maxLength.get();
		});
		this.kind = new Property(kind);
	}

	override function dispose()
	{
		maxLength.onChange.clear();
		maxLength = null;
		kind.onChange.clear();
		kind = null;
		super.dispose();
	}
}